package com.itheima.mapper;



import com.itheima.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author wuyiqiang
 * @2022/6/13 19:56
 */
@Mapper
public interface CategoryMapper {

    /**
     * 新增分类
     * @param category
     * @return
     */
    @Insert("insert into category values (#{id},#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    int add(Category category);

    /**
     * 分页查询
     *
     * @param pageMin
     * @param pageSize
     * @return
     */
    List<Category> page( Integer pageMin, Integer pageSize);

    /**
     * 下拉查询
     * @param type
     * @return
     */
    @Select("select * from category where type=#{type}")
    List<Category> dropDown(Integer type);

    /**
     * 删除分类
     * @param id
     * @return
     */
    @Delete("delete from category where id=#{id}")
    int delete(String id);

    /**
     * 计算总条数
     * @return
     */
    @Select("select count(*) from category")
    Integer countPage();

    /**
     * 修改分类
     * @param category
     * @return
     */
    int update(Category category);

    /**
     * 通过菜品id找到菜品信息
     * @param categoryId
     * @return
     */
    @Select("select * from category where id=#{id}")
    Category selectById(String categoryId);
}
